package hibernate_basic.Persistence.refresh_data;

import hibernate_basic.Persistence.comment_persitence.Person;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

/**
 * @author Administrator
 * @create 2018-12-31 10:06
 * @desc 更新数据表
 **/
public class RefreshData {

    public static void main(String args[])
    {
        Configuration config=new Configuration();
        config.configure("hibernate_basic/config/config_comment/hibernate.cfg.xml");
        SessionFactory sesfac=config.buildSessionFactory();
        Session session=sesfac.openSession();
        Transaction tran=session.beginTransaction();
        Person person=(Person)session.get(Person.class,new Integer("14"));
        person.setName("胡歌");
        person.setAge(36);
        person.setHeight(186.2);
        person.setWeight(65.6);
        tran.commit();
        session.flush();
        session.close();
    }






}
